//
//  JWTUserMemberView.m
//  JWT
//
//  Created by ndm on 17/2/12.
//  Copyright © 2017年 com.jwtsoft. All rights reserved.
//

#import "JWTUserMemberView.h"
#import "JWTChargeVipListViewController.h"
#import "JWTAlipayChargeVipViewController.h"

@implementation JWTUserMemberView

-(instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame] ;
    if (self) {
        
        self.backgroundColor = RGB(212, 212, 212);
        
        _vipInfoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, UISCREEN_WIDTH, UISCREEN_HEIGHT-getNAVI_TOP_HEIGHT())];
        _vipInfoView.backgroundColor = RGB_WhiteBackGround;
        [self addSubview:_vipInfoView];
        
        _vipTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(3*Cell_Margin, 3*Cell_Margin, UISCREEN_WIDTH-2*3*Cell_Margin, 34)];
        _vipTitleLabel.textColor = RGB_LightGray;
        _vipTitleLabel.font = [UIFont boldSystemFontOfSize:16.0];
        _vipTitleLabel.text = @"VIP";
        [_vipInfoView addSubview:_vipTitleLabel];
        
        _vipTypeLabel = [[UILabel alloc] initWithFrame:CGRectMake(_vipTitleLabel.left, _vipTitleLabel.bottom+2*Cell_Margin, UISCREEN_WIDTH*0.5, 50)];
        _vipTypeLabel.font = [UIFont boldSystemFontOfSize:25.0];
        _vipTypeLabel.textColor = HeaderBackground_Color;
        [_vipInfoView addSubview:_vipTypeLabel];
        
        _hintRecodeLabel = [[UILabel alloc] initWithFrame:CGRectMake(_vipTypeLabel.right,_vipTypeLabel.top,UISCREEN_WIDTH*0.5-3*Cell_Margin-20, 44)];
        _hintRecodeLabel.text = @"购卡历史";
        _hintRecodeLabel.font = Text_Font14;
        _hintRecodeLabel.textColor = RGB_LightGray;
        _hintRecodeLabel.textAlignment = NSTextAlignmentRight;
        [_vipInfoView addSubview:_hintRecodeLabel];
        _hintRecodeLabel.center = CGPointMake(_hintRecodeLabel.center.x, _vipTypeLabel.center.y);
        
        _nextImageView = [[UIImageView alloc] initWithFrame:CGRectMake(_hintRecodeLabel.right, _hintRecodeLabel.top, 15, 15)];
        _nextImageView.contentMode = UIViewContentModeScaleAspectFit;
        [_nextImageView setImage:[UIImage imageNamed:@"NextArrow"]];
        [_vipInfoView addSubview:_nextImageView];
        _nextImageView.center = CGPointMake(_nextImageView.center.x, _hintRecodeLabel.center.y);
        
        
        _vipInfoView.frame = CGRectMake(_vipInfoView.left, _vipInfoView.top, _vipInfoView.width, _vipTypeLabel.bottom+Cell_Margin*3);
        
        _vipRecordBtn = [[UIButton alloc] initWithFrame:_vipInfoView.frame];
        [_vipInfoView addSubview:_vipRecordBtn];
        
        [_vipRecordBtn addButtonBlockControlEvent:UIControlEventTouchUpInside withBlock:^(id sender) {
            JWTChargeVipListViewController *vc = [[JWTChargeVipListViewController alloc] init];
            [[[JWTAppTabBarTheme sharedInstance] getNavController] pushViewController:vc animated:YES];
        }];
        
        _vipChargeBtn = [[UIButton alloc] initWithFrame:CGRectMake(self.left, _vipInfoView.bottom+5*Cell_Margin, UISCREEN_WIDTH*0.5, 50)];
        _vipChargeBtn.layer.borderWidth = 0.5f;
        _vipChargeBtn.layer.cornerRadius = _vipChargeBtn.height * 0.5;
        _vipChargeBtn.layer.borderColor = RGB_LightGray.CGColor;
        [_vipChargeBtn setTitle:@"充 值" forState:UIControlStateNormal];
        [_vipChargeBtn setTitleColor:RGB_WhiteBackGround forState:UIControlStateNormal];
        _vipChargeBtn.backgroundColor = HeaderBackground_Color;
        
        [_vipChargeBtn addTarget:self action:@selector(pushToAlipayChargeVip:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_vipChargeBtn];
        _vipChargeBtn.center = CGPointMake(UISCREEN_WIDTH*0.5, _vipChargeBtn.center.y);
        


    }
    return self;
}

-(void) pushToAlipayChargeVip:(UIButton *)sender{
    JWTAlipayChargeVipViewController *vc = [[JWTAlipayChargeVipViewController alloc] init];
    [[[JWTAppTabBarTheme sharedInstance] getNavController] pushViewController:vc animated:YES];
}

@end
